import request from './request'
import type { Member } from '@/types'

export const getMembers = (params?: any) => {
  return request({
    url: '/member/page',
    method: 'post',
    data: {
      ...params
    }
  })
}

export const getMember = (id: number) => {
  return request({
    url: `/members/${id}`,
    method: 'get'
  })
}

export const createMember = (data: Partial<Member>) => {
  return request({
    url: '/member/add',
    method: 'post',
    data
  })
}

export const updateMember = (data: Partial<Member>) => {
  return request({
    url: `/member/update`,
    method: 'post',
    data
  })
}

export const deleteMember = (id: number) => {
  return request({
    url: `/members/${id}`,
    method: 'delete'
  })
}

// addBalance
export const addBalance = (data: { id: number, balance: number }) => {
  return request({
    url: `/member/addBalance`,
    method: 'post',
    data
  })
}
